package com.java250;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class GenericDemo {
    public static void main(String[] args) {
        // 创建集合对象
        Collection<String> c = new ArrayList<String>();

        // 添加元素
        c.add("hello");
        c.add("word");
        c.add("java");
//        c.add(100);


//        Iterator it = c.iterator();
        Iterator<String> it = c.iterator();
        while(it.hasNext()) {
//            Object obj = it.next();
            String s = it.next();
            System.out.println(s);
        }
    }
}
